﻿Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Exp.DAL
Imports Exp.Model
Public Class Season_Service
    Public Function GetAll() As List(Of REM_Season)
        Dim ctx As New EXPEntities
        Dim list = ctx.REM_Season.ToList()
        Return list
    End Function
    Public Function GetByID(ByVal iSeasonID As Integer) As REM_Season
        Dim ctx As New EXPEntities
        Dim obj = ctx.REM_Season.Where(Function(o) o.Season_ID = iSeasonID).FirstOrDefault()
        Return obj
    End Function
    Public Sub Add(objREM_Season As REM_Season)
        Dim ctx As New EXPEntities
        ctx.REM_Season.AddObject(objREM_Season)
        ctx.SaveChanges()
    End Sub
    Public Sub Delete(ByVal iSeasonID As Integer)
        Dim ctx As New EXPEntities
        Dim obj = ctx.REM_Season.Where(Function(o) o.Season_ID = iSeasonID).FirstOrDefault()
        ctx.REM_Season.DeleteObject(obj)
        ctx.SaveChanges()
    End Sub
    Public Sub Edit(objREM_Season As REM_Season)
        Dim ctx As New EXPEntities
        Dim obj = ctx.REM_Season.Where(Function(o) o.Season_ID = objREM_Season.Season_ID).FirstOrDefault()
        obj.SeasonCode = objREM_Season.SeasonCode
        ctx.SaveChanges()
    End Sub
    Public Function GetByName(ByVal sSeasonCode As String) As List(Of REM_Season)
        Dim ctx As New EXPEntities
        Dim lstObj As New List(Of REM_Season)
        lstObj = ctx.REM_Season.Where(Function(o) UCase(o.SeasonCode) = UCase(sSeasonCode)).ToList()
        Return lstObj
    End Function
End Class
